package com.muyu.payment.domain;

import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import com.muyu.payment.domain.req.PaymentConfigsQueryReq;
import com.muyu.payment.domain.model.PaymentConfigsSaveModel;
import com.muyu.payment.domain.model.PaymentConfigsEditModel;
import com.muyu.common.core.web.domain.BaseEntity;

/**
 * 支付配置数据库映射对象 payment_configs
 *
 * @author muyu
 * @date 2025-09-17
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("payment_configs")
@EqualsAndHashCode(callSuper = true)
public class PaymentConfigs extends BaseEntity {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "payment_id",type = IdType.AUTO)
    private Long paymentId;

    /**
     * 支付类型(1:微信 2:支付宝 3:其他)
     */
    @Excel(name = "支付类型(1:微信 2:支付宝 3:其他)")
    private Long payType;

    /**
     * 应用ID
     */
    @Excel(name = "应用ID")
    private String appId;

    /**
     * 商户号
     */
    @Excel(name = "商户号")
    private String merchantId;

    /**
     * 商户私钥
     */
    @Excel(name = "商户私钥")
    private String privateKey;

    /**
     * 平台公钥
     */
    @Excel(name = "平台公钥")
    private String publicKey;

    /**
     * 支付结果回调地址
     */
    @Excel(name = "支付结果回调地址")
    private String callbackUrl;

    /**
     * 配置名称
     */
    @Excel(name = "配置名称")
    private String configName;

    /**
     * 是否沙箱环境(0:正式环境 1:沙箱环境)
     */
    @Excel(name = "是否沙箱环境(0:正式环境 1:沙箱环境)")
    private String isSandbox;

    /**
     * 状态(0:禁用 1:启用)
     */
    @Excel(name = "状态(0:禁用 1:启用)")
    private String status;

    /**
     * 创建人
     */
    @Excel(name = "创建人")
    private String createBy;

    /**
     * 创建时间
     */
    @Excel(name = "创建时间")
    private Date createTime;

    /**
     * 修改人
     */
    @Excel(name = "修改人")
    private String updateBy;

    /**
     * 修改时间
     */
    @Excel(name = "修改时间")
    private Date updateTime;
    /**
     * 删除标志（0-未删除，1-已删除）
     */
    private Integer deleted;
    /**
     * 备注
     */
    @Excel(name = "备注")
    private String remark;
    /**
     * 添加构造器
     */
    public static PaymentConfigs saveModelBuild(PaymentConfigsSaveModel saveModel){
        return PaymentConfigs.builder()
            .payType(saveModel.getPayType())
            .appId(saveModel.getAppId())
            .merchantId(saveModel.getMerchantId())
            .privateKey(saveModel.getPrivateKey())
            .publicKey(saveModel.getPublicKey())
            .callbackUrl(saveModel.getCallbackUrl())
            .configName(saveModel.getConfigName())
            .isSandbox(saveModel.getIsSandbox())
            .status(saveModel.getStatus())
            .build();
    }

    /**
     * 修改构造器
     */
    public static PaymentConfigs editModelBuild(PaymentConfigsEditModel editModel){
        return PaymentConfigs.builder()
            .paymentId(editModel.getPaymentId())
            .payType(editModel.getPayType())
            .appId(editModel.getAppId())
            .merchantId(editModel.getMerchantId())
            .privateKey(editModel.getPrivateKey())
            .publicKey(editModel.getPublicKey())
            .callbackUrl(editModel.getCallbackUrl())
            .configName(editModel.getConfigName())
            .isSandbox(editModel.getIsSandbox())
            .status(editModel.getStatus())
            .build();
    }

}
